package main

import "fmt"

type Men interface {
	SayHi()
	Sing(lyrics string)
}

type UniversityStudent interface {
	SayHi()
	Sing(song string)
	LoveConsumption(amount float32) // 大学生恋爱消费(泡妞花钱)
}

// 码农
type CodeFarmer interface {
	SayHi()
	Sing(song string)
	BuyHouse(amount float32) // 买房结婚
}

type Human struct {
	name  string
	age   int
	phone string
}
type Student struct {
	Human  //匿名字段Human
	school string
	loan   float32
}
type Employee struct {
	Human   //匿名字段Human
	company string
	money   float32
}

//Human对象实现Sayhi方法
func (h *Human) SayHi() {
	fmt.Printf("Hi, I am %s you can call me on %s\n", h.name, h.phone)
}

// Human对象实现Sing方法
func (h *Human) Sing(lyrics string) {
	fmt.Println("La la, la la la, la la la la la...", lyrics)
}

//Student实现LoveConsumption方法
func (s *Student) LoveConsumption(amount float32) {
	s.loan += amount // (again and again and...)
}

// Employee重载Human的Sayhi方法
func (e *Employee) SayHi() {
	fmt.Printf("Hi, I am %s, I work at %s. Call me on %s\n", e.name, e.company, e.phone) //Yes you can split into 2 lines here.
}

//Employee实现BuyHouse方法
func (e *Employee) BuyHouse(amount float32) {
	e.money += amount // 何以解忧唯有暴富
}

func main() {
	h := Human{
		name:  "二狗",
		age:   20,
		phone: "1313131311",
	}
	// 学生
	s := Student{
		Human:  h,
		school: "挖掘机职业学院",
		loan:   20000,
	}
	// 员工
	e := Employee{
		Human:   h,
		company: "新东方",
		money:   2500,
	}
	h.SayHi()
	s.SayHi()
	e.SayHi()

	s.LoveConsumption(1000)
	e.BuyHouse(100)
	// 查看恋爱消费
	fmt.Println(s.loan)
	// 查看买房存款，好难
	fmt.Println(e.money)
}
